package com.example.zq.customerextends;


import com.alibaba.fastjson.JSON;
import com.example.zq.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Zhang Qi
 * @date : 2019/11/25
 */
@RestController
public class FeignHelloController {
  @Autowired
  private FeignHelloService feignHelloService;

  @GetMapping("/feignHello")
  public String feignHello(@RequestParam("name") String name){
    return feignHelloService.hello(name);
  }

  @GetMapping("/feignOpt")
  public void feignOpt(){
    User user=new User();
    user.setId(1);
    user.setUsername("Lime");
    user.setAddress("地球");
    User user1 = feignHelloService.addUser(user);
    System.out.println("新建用户:"+JSON.toJSONString(user1));
    feignHelloService.updateUserById("ZQ", 1);
    User user2 = feignHelloService.getUserById(1);
    System.out.println("修改用户:"+JSON.toJSONString(user2));
    feignHelloService.deleteUserById(1);
    User user3 = feignHelloService.getUserById(1);
    System.out.println("删除用户:"+user3);
  }
}
